#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = (1 << 20) + 5;
const int MOD = 998244353;
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
const int G = 3, invG = fastpow(3, MOD - 2);

// void ntt(vector<ll>& a, bool invert) {
//   int n = a.size();
//   if (n == 1) return;
//   vector<ll> a0(n / 2), a1(n / 2);
//   rep(i, 0, n / 2 - 1) {
//     a0[i] = a[i * 2];
//     a1[i] = a[i * 2 + 1];
//   }
//   ntt(a0, invert), ntt(a1, invert);
//   ll w1 = fastpow(invert ? invG : G, (MOD - 1) / n);
//   ll w = 1;
//   rep(i, 0, n / 2 - 1) {
//     ll u = a0[i], v = a1[i] * w % MOD;
//     a[i] = (u + v) % MOD;
//     a[i + n / 2] = (u - v + MOD) % MOD;
//     if (invert) {
//       a[i] = a[i] * inv2 % MOD;
//       a[i + n / 2] = a[i + n / 2] * inv2 % MOD;
//     }
//     w = w * w1 % MOD;
//   }
// }

void change(vector<int>& a) {
  int n = a.size();
  a[0] = 0;
  rep(i, 1, n - 1) { a[i] = (a[i >> 1] >> 1) + (i & 1 ? n / 2 : 0); }
}
void ntt(vector<ll>& a, bool invert) {
  int n = a.size();
  vector<int> rev(n);
  change(rev);
  rep(i, 0, n - 1) if (i < rev[i]) swap(a[i], a[rev[i]]);

  for (int len = 2; len <= n; len <<= 1) {
    ll w1 = fastpow(invert ? invG : G, (MOD - 1) / len);
    for (int i = 0; i < n; i += len) {
      ll w = 1;
      for (int j = 0; j < len / 2; j++) {
        ll u = a[i + j], v = a[i + j + len / 2] * w % MOD;
        a[i + j] = (u + v) % MOD;
        a[i + j + len / 2] = (u - v + MOD) % MOD;
        w = w * w1 % MOD;
      }
    }
  }
  if (invert) {
    ll m = fastpow(n, MOD - 2);
    for (ll& x : a) x = x * m % MOD;
  }
}

vector<ll> multiply(const vector<ll>& a, const vector<ll>& b) {
  vector<ll> fa(a.begin(), a.end()), fb(b.begin(), b.end());
  int n = 1;
  while (n < a.size() + b.size() - 1) n <<= 1;
  fa.resize(n), fb.resize(n);
  ntt(fa, 0), ntt(fb, 0);
  rep(i, 0, n - 1) fa[i] = fa[i] * fb[i] % MOD;
  ntt(fa, 1);
  return fa;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<ll> a(n + 1, 0), b(m + 1, 0);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, m) cin >> b[i];
  vector<ll> c = multiply(a, b);
  rep(i, 0, n + m) cout << c[i] << ' ';
  return 0;
}